# 求三角形面积
# print('求三角形面积算法')
# import math
# a=int(input('请输入边长a：'))
# b=int(input('请输入边长b：'))
# c=int(input('请输入边长c：'))
# if a+b>c and a+c>b and b+c>a and a>0 and b>0 and c>0:
#    p=(a+b+c)/2
#    result=math.sqrt(p*(p-a)*(p-b)*(p-c))
#    print('这个三角形的面积是：',result)
# else:
#    print('这三边不能构成三角形')

# if嵌套结构
# print('求三角形面积算法')
# import math
# a=int(input('请输入边长a：'))
# b=int(input('请输入边长b：'))
# c=int(input('请输入边长c：'))
# if a>0 and b>0 and c>0 :
#     if a+b>c and a+c>b and b+c>a:
#        p = (a + b + c) / 2
#        result=math.sqrt(p*(p-a)*(p-b)*(p-c))
#        print('这个三角形的面积是：',result)
#     else:
#        print('两边之和小于第三边')
# else:
#    print('边长不大于0')


# if...elif...else结构
# age=int(input('please input your age:'))
# if 0<age <18:
#     print('青少年')
# elif 18<=age<=45:
#     print('中年')
# elif 45<=age<140:
#     print('老年')
# else:
#     print('输入不合法')

# import math
# a=int(input('请输入边长a：'))
# b=int(input('请输入边长b：'))
# c=int(input('请输入边长c：'))
# if a<=0 or b<=0 or c<=0 :
#     print('错')
# elif a+b<=c or a+c<+b or b+c<=a:
#     print('错')
# else:
#     p = (a + b + c) / 2
#     result = math.sqrt(p * (p - a) * (p - b) * (p - c))
#     print('这个三角形的面积是：', result)

# if的三元运算  expression1 if condition else expression2
# >>> str1='abcddd'
# >>> result= 'ok' if str1[:3]=='abc' else 'no'
# >>> result= 'ok' if str1.startwith('abc') else 'no'
# >>> result
# 'ok'

# 验证用户名和密码
# login=input('localhost login:')
# passwd=input('passwd:')
# result=print('login succeed') if login=='root' and passwd=='123456' else print('login incorrect')

# 隐藏密码输入
# import getpass
# login=input('localhost login:')
# passwd=getpass.getpass('passwd:')   ###这种方法在pycharm中不友好
# result=print('login succeed') if login=='root' and passwd=='123456' else print('login incorrect')

# for循环
# str1=input('please input a string:')
# result=''
# for i in str1:
#     if i.isupper():
#         result +='1'  #print('1',end='')也可以同行输出
#     else:
#         result +='0'
# print(result)

# break continue
#  break 结束当前循环
# continue 结束本次循环，开始下一次循环
# 嵌套循环：时间复杂度：a*b
# a=3
# b=4
# for j in range(a):
#     for i in range(b):
#         if i==1:
#            #break
#             continue
#         print(j,i)

# 找到一个随机字符串中出现次数最多的字符
# 代码一
# import random
# str1 = random.choices('abcdefghijk', k=20)
# str2 = ''.join(str1)
# num=0
# for i in str2:
#     num1=str2.count(i)
#     if num1>=num:
#         num=num1
#         j=i
# print(j,str2)

# 定义两个变量去存储出现字符和次数
# 代码二
# import random
# str1 = random.choices('abcdefghijk', k=20)
# str2 = ''.join(str1)
# tmp_str=''
# max_num=0
# for i in str2:
#     if str2.count(i)>max_num:
#         max_num=str1.count(i)
#         tmp_str=i
# print(str2,tmp_str,max_num)

# 用户登录验证
#    登录成功或失败都给予提示
#    最多可尝试3次密码
#
# for i in range(3):
#     j=0
#     j+=1
#     login = input('localhost login:')
#     passwd = input('passwd:')
#     if  login=='root' and passwd=='123456' :
#         print('login succeed')
#         break
#     elif j<3:
#         print('login incorrect')
#     else:
#         print('you have no chance')

# result=print('login succeed') if login=='root' and passwd=='123456' else print('login incorrect')

# 猜数字
# • 在程序内定义一个数字，让用户猜
# • 检查用户输入的是否为数字
# • 键盘接收用户输入，猜对或猜错都给出提示（大/小）
# • 最多能猜3次
# • 给出用户最终猜的结果，及花了几次来猜
# import random
# num = random.randint(1,10)
# for i in range(3):
#     j=0
#     j+=1
#     num1 = input('请猜一个数：')
#     if  not num1.isdigit():
#         print('你输入的不是数字')
#     elif num==num1:
#         print('猜对了!','你猜了',j,'次')
#         break
#     elif j<3:
#         if num1<num:
#              print('往大了猜')
#         elif num1>num :
#              print('往小了猜')
# else:
#             print('三次都不对，太笨了，哈哈哈')
# else:                 #for循环执行完了才会执行else
#     print('三次都不对，太笨了，哈哈哈')
# else:
#     pass     #占位符，仅仅占一个位置，啥也不干

# 给你一个 32 位的有符号整数 x ，返回将 x 中的数字部分反转后的结果。
# 如果反转后整数超过 32 位的有符号整数的范围-2**32<=x<=2**32-1 ，就返回0
# import random
# str1=str(random.randint(-1000,1000))
# str2=

# while循环
# i=1
# while i<5:
#     i+=1
#     print('ok',i)
# else:
#     print('false')

# 用while循环实现用户登录验证
# j=1
# while j<4:
#     j+=1
#     login = input('localhost login:')
#     passwd = input('passwd:')
#     if  login=='root' and passwd=='123456' :
#         print('login succeed')
#         break
#     elif j<4:
#         print('login incorrect')
#     else:
#         print('you have no chance')

###################
# capital本金
# accrual利息
# target目标
# capital=int(input('请输入您的预存本金：'))
# target=int(input('请输入您的目标本息和：'))
# year=0
# summary = capital+capital * 0.05*year
# while summary<target:
#     capital=summary
#     summary = capital+capital * 0.05
#     year+=1
#     print('您存款的第',year,'年','将得到的本息和为%.2f'%summary,'元。')
# print('您需要存款',year,'年，才能达到您的目标本息和。')


# 空气质量查询工具
# • 键盘接收pm2.5的值
# • 根据右表，计算出今天的空气质量
# • 循环输入，按q退出
# while 1:
#     pm=input('请输入PM2.5的值：')
#     if pm=='q':
#         break
#     elif  51<=int(pm)<=100:
#         print('良')
#     elif  101<=int(pm)<=150:
#         print('轻度污染')
#     elif  151<=int(pm)<=200:
#         print('中度污染')
#     elif  201<=int(pm)<=300:
#         print('重度污染')
#     elif  0<int(pm)<=50:
#         print('优')
#     elif int(pm)>300:
#         print('严重污染')

# import random
# win_time = 0  #赢的次数初始化为零
# lose_time = 0   #输的次数初始化为零
# capial=1000    #金豆初始化为1000
# while capial>=100:
#     a = random.randint(1, 6)
#     b = random.randint(1, 6)
#     c = random.randint(1, 6)    #随机取3个1~6之间的整数
#     sum = a + b + c
#     user=input('Please input big or little or exit:')   #用户输入
#     if user!='exit' and user!='big' and user!='little':
#         print('Your input format is incorrect')
#     if user=='exit' :
#         break      #用户输入为exit，退出程序
#     print('The summary is ',sum)      #显示三个骰子的总数
#     if (3<=sum<=10 and user=='little') or (11<=sum<=18 and user=='big'):  #判定用户输入与骰子总数关系
#         win_time += 1  #赢的次数加一
#         capial+=100    #金豆加一百
#         print('Congratulations!You win!','now you have already won',win_time,"times","and now your capital is",capial,'￥')
#     elif (3<=sum<=10 and user=='big') or (11<=sum<=18 and user=='little'):   #判定用户输入与骰子总数关系
#         lose_time += 1   #输的次数加一
#         capial-=100    #金豆减一百
#         print('Regretful!You lose!','Now you have already lost',lose_time,'times',"and now your capital is",capial,'￥')
#     sum_times=win_time+lose_time   #玩的总次数
#     win_rate = win_time/sum_times * 100   #胜率算式
#     win_rate=int(win_rate)    #胜率保留整数
#     if sum_times>=10 and win_rate>=60:     #奖励机制：游戏次数在10把以上，且胜率高于60%，奖励200￥
#         capial+=200
#         print('Your win rate are over 80%,we will reward you 200￥,and now you have',capial,'￥')
#     print('Now your win rate is',win_rate,'%')
#     print('You have played it',sum_times,'times')

# import random
# win_time = 0  #赢的次数初始化为零
# lose_time = 0   #输的次数初始化为零
# capial=1000    #金豆初始化为1000
# while capial>=100:
#     a = random.randint(1, 6)
#     b = random.randint(1, 6)
#     c = random.randint(1, 6)    #随机取3个1~6之间的整数
#     sum = a + b + c
#     user=input('Please input big or little or exit:')   #用户输入
#     if user!='big' and user!='little' and user!='exit':  #输入格式不对，给予提示
#         print('Your input format is incorrecet')
#     else:
#         if user=='exit' :
#             print('game over')
#             break      #用户输入为exit，退出程序
#         print('The summary is ',sum)      #显示三个骰子的总数
#         if (3<=sum<=10 and user=='little') or (11<=sum<=18 and user=='big'):  #判定用户输入与骰子总数关系
#             win_time += 1  #赢的次数加一
#             capial+=100    #金豆加一百
#             print('Congratulations!You win!','now you have already won',win_time,"times","and now your capital is",capial,'￥')
#         elif (3<=sum<=10 and user=='big') or (11<=sum<=18 and user=='little'):   #判定用户输入与骰子总数关系
#             lose_time += 1   #输的次数加一
#             capial-=100    #金豆减一百
#             print('Regretful!You lose!','Now you have already lost',lose_time,'times',"and now your capital is",capial,'￥')
#         sum_times=win_time+lose_time   #玩的总次数
#         win_rate = win_time/sum_times * 100   #胜率
#         if sum_times>=10 and win_rate>=60:     #奖励机制：游戏次数在10把以上，且胜率高于60%，奖励200￥
#             capial+=200
#             print('Your win rate are over 60%,we will reward you 200￥,and now you have',capial,'￥')
#         print('Now your win rate is %.2f%%'%win_rate)
#         print('You have played it',sum_times,'times')



# import random
# glod_bean = 1000
# while glod_bean >= 100:
#     guess = input("请在键盘输入大或小：")
#     a = random.randint(1, 6)
#     b = random.randint(1, 6)
#     c = random.randint(1, 6)
#     sum = a + b + c
#     if guess != "exit":
#         if (3 <= sum <= 10 and guess == "小") or (11 <= sum <= 18 and guess == "大"):
#             print("结果为", sum)
#             glod_bean += 100
#             print("恭喜你猜中了！当前金豆为", glod_bean)
#         elif (3 <= sum <= 10 and guess == "大") or (11 <= sum <= 18 and guess == "小"):
#             print("结果为", sum)
#             glod_bean -= 100
#             print("很遗憾你猜错了，当前金豆为", glod_bean)
#     else:
#         break
# print("game over!")


# for循环实现输出九九乘法表
# for i in range(1, 10):
#     for j in range(1, i+1):
#         print(f'{j}x{i}={i*j}\t', end='')
#     print()

# while循环实现输出九九乘法表
# i = 1
# while i <= 9:
#     j = 1
#     while(j <= i):    # j的大小是由i来控制的
#         print(f'{i}*{j}={i*j}', end='\t')
#         j += 1
#     print('')
#     i += 1

# while，for一起实现输出九九乘法表
# i = 1
# while i <= 9:
#     for j in range(1, i+1):  # range()函数左闭右开
#         print(f'{i}*{j}={i*j}', end=' ')
#     i += 1
#     print()

# 一行语句实现输出九九乘法表
# print('\n'.join([' '.join([f"{j}x{i}={i*j}" for j in range(1, i + 1)]) for i in range(1, 10)]))



# 给定一个字符串 (s) 和一个字符模式 (p) ，实现一个支持 '?' 和 '*' 的通配符匹配
# s 可能为空，且只包含从 a-z 的小写字母。
# p 可能为空，且只包含从 a-z 的小写字母，以及字符 ? 和 *。
s=input('please input a string:')
p=input('please input the string you wanna match:')
if '*' not in p:
    if len(s)==len(p):
        print(s==p or 'false')
else :
    num1=p.count('*')
    if num1==1:
        if p[0]=="*" :
            s=s[::-1]
            p=p[::-1]
            i=0
            while p[i]!='*':
                if p[i]==s[i]:
                    i=i+1
                else:
                    print('false')
                    break
            else:
                print('true')
        elif p[len(p)-1]=='*':
            i=0
            while p[i]!='*':
                if p[i]==s[i]:
                    i=i+1
                else:
                    print('false')
                    break
            else:
                print('true')
        else:
            p1=p.split('*')
            if s[:len(p1[0])]==p1[0]:
                print(s[-(len(p1[1])):]==p1[1] and 'true' or 'false')
            else:
                print('false')


